const express = require("express");
const path = require("path")
const app = express();
const renderCharts = require('./controller/charts')
const config = require("./config")
app.use
//配置静态路径
app.use(express.static(path.join(__dirname, "./resource")))
app.use(express.static(path.join(__dirname, "./dist/html")))

//配置请求体解析
app.use(express.urlencoded({extended: true}))
//解析json格式的请求体
app.use(express.json())
//将ejs设置为默认的模板引擎
app.set("view engine", "ejs")
//设置模板路径
app.set("views", path.resolve(__dirname, "views"))
//调试界面
app.get("/", (req, res, next)=>{
  res.render("chartsDebug")
})
//接口
app.post("/echarts", renderCharts)

app.listen(config.port, () =>{
  //服务器启动后，执行
  console.log("服务器已经启动！")
})